#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
const int N = 1010;
int f[N][N];
string s;
int main()
{
	cin >> s;
	int n = s.size();
	for (int len = 1; len <= n; len++) {
		for (int l = 0; l + len - 1 < n; l++) {
			int r = l + len - 1;
			if (len == 1) {
				f[l][r] = 1;
			}
			else {
				if (s[l] == s[r]) {
					f[l][r] = f[l + 1][r - 1] + 2;
				}
				f[l][r] = max(f[l][r], f[l][r - 1]);
				f[l][r] = max(f[l][r], f[l + 1][r]);
			}
		}
	}
	cout << n - f[0][n - 1] << endl;
	return 0;
}